package thn.glf.org.personalfinancial.objData;

import java.util.ArrayList;

import thn.glf.org.lib.SQLiteDB;

import android.content.Context;
import android.database.Cursor;

public class FinancialYear {
	public static String TableName = "tblFinancialYear";
	public static String Field_YearID = "YearID";
	public static String Field_MoneyUse = "MoneyUse";
	public static String Field_YearFrom = "YearFrom";
	public static String Field_YearTo = "YearTo";
	private int YearID;
	private double MoneyUse;
	private String YearFrom;
	private String YearTo;
	private Context mContext;

	public FinancialYear() {

	}

	public int getYearID() {
		return YearID;
	}

	public void setYearID(int yearID) {
		YearID = yearID;
	}

	public double getMoneyUse() {
		return MoneyUse;
	}

	public void setMoneyUse(double moneyUse) {
		MoneyUse = moneyUse;
	}

	public String getYearFrom() {
		return YearFrom;
	}

	public void setYearFrom(String yearFrom) {
		YearFrom = yearFrom;
	}

	public String getYearTo() {
		return YearTo;
	}

	public void setYearTo(String yearTo) {
		YearTo = yearTo;
	}

	public ArrayList<FinancialYear> getList() {
		SQLiteDB db=new SQLiteDB(mContext);
		db.open();
		ArrayList<FinancialYear>datalist=new ArrayList<FinancialYear>();
		Cursor mCursor=db.query(true, TableName, new String[]{Field_YearID,Field_YearFrom,Field_YearTo,Field_MoneyUse}, null, null, null, null, Field_YearID, null);
		if (mCursor!=null &&  mCursor.moveToFirst()) {
			do{
				FinancialYear obj=new FinancialYear();
				obj.setYearID(mCursor.getInt(mCursor.getColumnIndex(Field_YearID)));
				obj.setYearFrom(mCursor.getString(mCursor.getColumnIndex(Field_YearFrom)));
				obj.setYearTo(mCursor.getString(mCursor.getColumnIndex(Field_YearTo)));
				obj.setMoneyUse(mCursor.getDouble(mCursor.getColumnIndex(Field_MoneyUse)));
				datalist.add(obj);
			}while(mCursor.moveToNext());
		}
		db.close();
		return datalist;
	}
}
